<?php
define('IN_ECS', true);
require(dirname(__FILE__) . '/includes/init.php');

//获取是否已授权
$count = $db->getOne("SELECT COUNT(id) FROM ".$ecs->table('wxauthorizer')." WHERE authorizer_status=1 AND seller_id=".$_SESSION['seller_id']);
if($count > 0 )
{
	echo "<script>window.location.href='wxaction.php?act=reply_subscribe'</script>";
	
}else
{
	include_once "wxstore/wxAuthLib.php";

	$wxauth = new wxAuthLib();
	$param = $wxauth->getHrefParam();
	$component_appid = $param['component_appid'];
	$pre_auth_code = $param['pre_auth_code'];
	$redirect_uri = $param['redirect_uri'];
	$wxHref = "https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid=".$component_appid."&pre_auth_code=".$pre_auth_code."&redirect_uri=".$redirect_uri;
	$smarty->assign('wxHref',$wxHref);
	assign_query_info();
	$smarty->display("wx_auth.htm");
}


?>

